/**
 * 
 */
package com.fwzc.giuseppe.activity;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import com.fwzc.giuseppe.R;
import com.fwzc.giuseppe.base.BaseActivity;
import com.fwzc.giuseppe.util.isMobileUtil;

/**
 * 
 * 类名称：RegisterActivity 类描述： 创建人：何琳 创建时间：2015年8月13日 下午12:13:28
 * 
 * @version
 * 
 */
public class RegisterActivity extends BaseActivity implements OnClickListener {

	private TextView regiser;
	private EditText username, code, password, school, studentId;// 用户名,验证码,密码,学校,学号
	private Button getCode;// 获取验证码
	private String mobile,codes,pwd;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.layout_register);

		initBar();
		initView();
		initData();
	}

	private void initView() {
		regiser = (TextView) findViewById(R.id.registerBtn);
		username = (EditText) findViewById(R.id.reg_username);
		code = (EditText) findViewById(R.id.reg_code);
		password = (EditText) findViewById(R.id.reg_password);
		school = (EditText) findViewById(R.id.reg_school);
		studentId = (EditText) findViewById(R.id.reg_studentid);

		getCode = (Button) findViewById(R.id.getcode_btn);
	}

	private void initData() {
		mobile = username.getText().toString().trim();
		codes = code.getText().toString().trim();
		pwd = password.getText().toString().trim();
		iv_actionbar_side_left.setVisibility(View.VISIBLE);
		regiser.setOnClickListener(this);
		getCode.setOnClickListener(this);
		iv_actionbar_side_left.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		if (v == regiser) {// 注册
			if ("".equals(mobile)) {
				Toast.makeText(RegisterActivity.this, "请输入手机号!",
						Toast.LENGTH_SHORT).show();
				return;
			}else if ("".equals(codes)) {
				Toast.makeText(RegisterActivity.this, "请输入验证码!",
						Toast.LENGTH_SHORT).show();
				return;
			}else if ("".equals(pwd)) {
				Toast.makeText(RegisterActivity.this, "请设置密码!",
						Toast.LENGTH_SHORT).show();
				return;
			}else {
				sendRegisterRequest();
			}
			
		} else if (v == getCode) {// 获取验证码
			if (!isMobileUtil.isMobileNumber(mobile)) {
				Toast.makeText(this, "请输入正确手机号！", Toast.LENGTH_SHORT).show();
				return;
			} else {
				sendgetCodeRequest();
			}
		} else if (v == iv_actionbar_side_left) {
			finish();
		}

	}

	/**
	 * 发送注册请求
	 */
	private void sendRegisterRequest() {
		// TODO Auto-generated method stub
		
	}

	/**
	 * 获取验证码请求
	 */
	private void sendgetCodeRequest() {
		// TODO Auto-generated method stub

	}

}
